package com.yt.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class MyThread {

	
	
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		
		ExecutorService threadPool = Executors.newCachedThreadPool();
		
		ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(threadPool);
		
		for(int i = 0;i<1000;i++){
			Demo demo = new Demo(i);
			Future<String> submit= completionService.submit(demo);
			System.out.println("future"+submit.get());
		}
		
		
		//executorCompletionService.submit(print(2));
	}
	
	/*public static Callable<String> print(int i){
		System.out.println(i+"<===");
		return null;
	}*/
}
